<%
  # Redmine plugin for Document Management System "Features"
  #
  # Karel Pičman <karel.picman@kontron.com>
  #
  # This program is free software; you can redistribute it and/or
  # modify it under the terms of the GNU General Public License
  # as published by the Free Software Foundation; either version 2
  # of the License, or (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
%>

<h3 class="title"><%= l(:field_label_dmsf_workflow) %></h3>
<% remote = params[:dmsf_link_id] || params[:attachment_id] %>
<%= form_tag({ controller: 'dmsf_workflows', action: 'assignment' }, method: :post, id: 'assignment-form',
             remote: remote) do %>
  <%= hidden_field_tag :dmsf_file_revision_id, params[:dmsf_file_revision_id] %>
  <%= hidden_field_tag :dmsf_link_id, params[:dmsf_link_id] %>
  <%= hidden_field_tag :attachment_id, params[:attachment_id] %>
  <%= hidden_field_tag :back_url, params[:back_url] %>
  <p>
    <%= label_tag 'workflow', "#{l(:link_workflow)}:" %>
    <%= select_tag 'dmsf_workflow_id', dmsf_workflows_for_select(@project, nil)%>
  </p>
  <% if (!remote) && User.current.allowed_to?(:manage_workflows, @project) %>
    <p>
      <%= link_to sprite_icon('add', l(:label_dmsf_workflow_new)), new_dmsf_workflow_path(project_id: @project.id),
                  class: 'icon icon-add' %>
    </p>
  <% end %>
  <p class="buttons">
    <%= submit_tag l(:button_submit), name: 'commit', onclick: 'hideModal(this);' %>
    <%= submit_tag l(:button_cancel), name: 'commit', onclick: 'hideModal(this);' %>
  </p>
<% end %>
